﻿using MyFirstWPF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MaterialDesignThemes.Wpf;

namespace MyFirstWPF.View.Compnent
{
    /// <summary>
    /// NoticeTask.xaml 的交互逻辑
    /// </summary>
    public partial class NoticeTask : UserControl
    {
        private TaskInfo Task;

        /// <param name="task">父page</param>
        /// <param name="type">提示类型，0=>任务结束前的提醒; 1=>每日任务提醒</param>
        public NoticeTask(TaskInfo task,int type)  
        {
            InitializeComponent();
            this.Task = task;
            tbName.Text = task.Name;
            tbStartTime.Text = task.StartTime;
            tbDesc.Text = task.Description;

            if (type == 0) {
                TimeSpan span = task.GetStartTime() - DateTime.Now;
                string showNotice = "还有" + span.Minutes + "分钟任务开始，请做好准备！！";
                tbNotice.Text = showNotice;
            } else if(type == 1){
                TimeSpan span = Window2.GetHHMMSS(task.GetStartTime()) - Window2.GetHHMMSS(DateTime.Now);
                string showNotice = "还有" + span.Minutes + "分钟开始日常任务，请及时做好准备！";
                tbNotice.Text = showNotice;
            }
        }

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            DialogHost.CloseDialogCommand.Execute(null, null);
        }
    }
}
